package com.apes.auto.car.service;

import com.apes.auto.car.model.CarBrand;
import com.apes.auto.car.repository.CarBrandRepository;
import com.apes.framework.api.DomainService;
import com.apes.framework.plugin.esb.api.SimpleRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName CarBrandService
 * @Description TODO
 * @Author pengyb
 * @Date 2019/7/9 15:34
 * @Version 1.0
 **/
@Service("dcCarBrandService")
public class CarBrandService extends DomainService {
    @Autowired
    private CarBrandRepository carBrandRepository;

    /**
     * 保存
     *
     * @param request
     * @return
     */
    public CarBrand save(SimpleRequest request) {
        CarBrand o = request.getO(CarBrand.class);
        return carBrandRepository.saveAndFlush(o);
    }

    public List<CarBrand> BatchSave(Iterable<CarBrand> brandMessages) {
        return carBrandRepository.save(brandMessages);
    }

    public String delete(SimpleRequest request){
        CarBrand o = request.getO(CarBrand.class);
        carBrandRepository.delete(o.getId());
        return "删除成功";
    }
}
